setwd("/homes/jc227089/SRE/oneD/DispEvol/PBS")


script.file<-'/homes/jc227089/evo-dispersal/SRE/SRE1DEvol.R'

reps<-50
jobID<-"oneDEvol"

for (jj in 1:reps){
	fID<-jj
	##create the sh file
	zz = file(paste(jobID, fID,'.sh',sep=''),'w')
	cat('##################################\n',file=zz)
	cat('#!/bin/sh\n',file=zz)
	cat('cd $PBS_O_WORKDIR\n',file=zz)
	cat("R CMD BATCH --no-save --no-restore '--args ngens.init=500 ngens.final=5000 beta=-0.005 fID=",fID, sep="", file=zz)
	cat("' ", script.file, " ", paste(jobID, fID,'.Rout',sep=''), "\n", sep="",file=zz)
	cat('##################################\n',file=zz)
	close(zz)
			
		#submit the job
		system(paste("qsub -m n ", paste(jobID, fID,".sh",sep=""),sep=""))
}
